package cn.jaye.fabric.common.thread;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @author Jaye
 * @create 2018-04-03 14:32
 */
public class UserContextHolder {
    private static final ThreadLocal<String> contextHolder = new ThreadLocal<String>();

    public static Map<String, Date> userInfo = new HashMap<>();

    public static void setUser(String username) {
        contextHolder.set(username);
    }

    public static String getUser() {
        return contextHolder.get();
    }

    public static void clearUser() {
        contextHolder.remove();
    }

    //判断用户是否存在
    public static boolean containsUser(String username) {
        return userInfo.containsKey(username);
    }
}
